//
//  E7Town.h
//  EndlessBattle
//
//  Created by cc on 12-3-17.
//  Copyright (c) 2012年 PalmGame. All rights reserved.
//

#ifndef EndlessBattle_E7Town_h
#define EndlessBattle_E7Town_h

#include "E7GameDefine.h"

class CE7Town
{
public:
    CE7Town() ;
    ~CE7Town() ;

    bool InitData(int nID, int countryid, int gold) ;
    bool ResetCityCell() ;
    bool Destroy() ;
    bool AddCell(int nID) ;
    bool DelCell(int nID) ;

    bool AttachTown(int nID) ;
    bool DetachTown() ;
    void DetachCell(int nID) ;

    void Balance() ;
    void BalanceInit() ;

//private:
    bool AddUnit(int nID) ;
    bool DelUnit(int nID) ;
    bool SetAllUnitDead() ;

private:
    
    bool CheckNeighborCell(CE7Cell* pStart) ;
    void ChangeCellTownID(CE7Town* pTown, CE7Cell* pStart) ;
    void FilterDetachCell(CE7Cell* pStart) ;

public:
    int GetID()          { return m_nID ; }
    int GetCountryID()   { return m_nCountryID ; }
    int GetGold()        { return m_nGold ; }
//    int GetOutGold()     { return m_nOutGold ; }
    int GetInGold()      { return m_nInGold ; }

    void SetID(int nID)              { m_nID = nID ; }
    void SetCountryID(int countryid) { m_nCountryID = countryid ; }
    void SetGold(int newgold)        { m_nGold = newgold ; if (0 > m_nGold) { m_nGold = 0 ; }  }
//    void SetOutGold(int newgold)     { m_nOutGold = newgold ; }
    void SetInGold(int newgold)      { m_nInGold = newgold ; }
public:
    UNIT_ID_LIST    m_listUnitIDs ; // all units.
    CELL_ID_LIST    m_listCellIDs ; // all cell indexs.

private:
    int             m_nID ;         // id.
    int             m_nCountryID ;  // countryid.
    int             m_nGold ;       // now gold.
//    int             m_nOutGold ;    // out gold.
    int             m_nInGold ;     // in gold.
};

#endif










